import { request, config } from 'utils'
const { api } = config
const { testPlan } = api

export async function query (params) {
  return request({
    url: testPlan+'/'+params.pk,
    method: 'get',
    data: params,
  })
}

export async function create (params) {
  let data=''
  for( let index in params){
    if(params[index]){
      data+=index+"="+params[index]+"&"
    }
  }
  data=data.slice(0,-1)
  return request({
    url: testPlan+'/add/',
    method: 'post',
    data: data,
  })
}

export async function remove (params) {
  return request({
    url: testPlan+'/delete/'+params.pk,
    method: 'delete',
    data: params,
  })
}

export async function update (params) {
  let data=''
  for( let index in params){
    if(params[index]){
      data+=index+"="+params[index]+"&"
    }
  }
  data=data.slice(0,-1)
  return request({
    url: testPlan+'/edit/'+params.pk,
    method: 'post',
    data: data,
  })
}
